using System.ComponentModel.DataAnnotations;

namespace TerritoryGame.Domain.ValueObjects;

/// <summary>
/// 游戏名称值对象
/// </summary>
public record GameName
{
    public string Value { get; }
    
    public GameName(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("游戏名称不能为空", nameof(value));
            
        if (value.Length < 2 || value.Length > 50)
            throw new ArgumentException("游戏名称长度必须在2-50个字符之间", nameof(value));
            
        Value = value.Trim();
    }
    
    public static implicit operator string(GameName name) => name.Value;
    
    public override string ToString() => Value;
}
